import { http } from "@/utils/http/axios";
const baseProfix = "/system/user";
/**
 * 获取用户
 * @returns
 */
export function getPageList(params = {}) {
	return http.request<API.Response.BasicResponse>(
		{
			url: `${baseProfix}/page`,
			method: "get",
			params
		},
		{
			isTransformResponse: false
		}
	);
}
export function getListByDept(deptId: any, params: any) {
	return http.request<API.Response.BasicResponse>(
		{
			url: `${baseProfix}/list/dept/${deptId}`,
			method: "get",
			params: params
		},
		{
			isTransformResponse: false
		}
	);
}
// 保存用戶
export function save(params = {}) {
	return http.request<API.Response.BasicResponse>(
		{
			url: baseProfix,
			method: "POST",
			data: params
		},
		{
			isTransformResponse: false
		}
	);
}
// 修改用戶
export function update(params = {}) {
	return http.request<API.Response.BasicResponse>(
		{
			url: baseProfix,
			method: "PUT",
			data: params
		},
		{
			isTransformResponse: false
		}
	);
}
/**
 * 删除用户
 * @param ids 职位ID
 * @returns
 */
export function remove(id: number | Array<number>) {
	return http.request<API.Response.BasicResponse>(
		{
			url: `${baseProfix}/${id}`,
			method: "DELETE"
		},
		{
			isTransformResponse: false
		}
	);
}
/**
 * 获取部门树
 */
export function deptTree() {
	return http.request<API.Response.BasicResponse>({
		url: `${baseProfix}/deptTree`,
		method: "GET"
	});
}
/**
 * 根据ID查询
 * @param id
 * @returns
 */
export function getUser(id: number) {
	return http.request<API.Setting.UserResponse>(
		{
			url: `${baseProfix}/${id}`,
			method: "get"
		},
		{
			isTransformResponse: true
		}
	);
}
/**
 * 重置密码
 * @param params
 * @returns
 */
export function restPassword(params = {}) {
	return http.request<API.Response.BasicResponse>({
		url: `${baseProfix}/resetPwd`,
		method: "PUT",
		data: params
	});
}
/**
 * 更改用户状态
 * @returns
 */
export function changeStatus(data = {}) {
	return http.request<API.Response.BasicResponse>({
		url: `${baseProfix}/changeStatus`,
		method: "PUT",
		data: data
	});
}

// 搜索用户
export function search(params = {}) {
	return http.request<API.Response.BasicResponse>({
		url: `${baseProfix}/search`,
		method: "get",
		params
	});
}
